/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div>
      <div class="fixed-bar">
        <div class="item-title">
          <router-link class="back" :to="{name:'expose_subject'}" title="返回列表">
            <i class="fa fa-arrow-circle-o-left"></i>
          </router-link>
          <div class="subject">
            <h3>举报管理</h3>
            <h5>商城设置举报类型及处理被举报商品</h5>
          </div>
        </div>
      </div>
      <form :model="form">
        <div class="ncap-form-default">
          <dl class="row">
            <dt class="tit">
              <label>举报类型</label>
            </dt>
            <dd class="opt">
              <el-radio-group v-model="form.expose_subject_type_id">
                <el-radio
                  v-for="type in expose_type"
                  :label="type.expose_type_id"
                  :key="type.expose_type_id"
                >
                  {{type.expose_type_name}}
                  : {{type.expose_type_desc}}
                </el-radio>
              </el-radio-group>
              <p
                class="err-msg"
                v-if="errResult.expose_subject_type_id && !form.expose_subject_type_id"
              >{{errResult.expose_subject_type_id}}</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>
                <em>*</em>举报主题
              </label>
            </dt>
            <dd class="opt">
              <input v-model="form.expose_subject_content" type="text" class="input-txt" />
              <p
                class="err-msg"
                v-if="errResult.expose_subject_content && !form.expose_subject_content"
              >{{errResult.expose_subject_content}}</p>
            </dd>
          </dl>
          <div class="bot">
            <el-button type="primary" @click="onSubmit()" :loading="isLoading">确认提交</el-button>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
import { addExpostSubject, getExpostTypeList } from "@/utils/api";
export default {
  data() {
    return {
      form: {
        expose_subject_type_id: null
      },
      radio: "1",
      expose_type: null,
      isLoading: false,
      errResult: {}
    };
  },
  created() {
    this.getType();
  },
  methods: {
    getType() {
      var that = this;
      getExpostTypeList().then(function(res) {
        that.expose_type = res;
        that.form.expose_subject_type_id = that.expose_type[0].expose_type_id;
      });
    },
    onSubmit() {
      this.isLoading = true;
      var that = this;
      addExpostSubject(that.form).then(function(res) {
        if (res.status == 1) {
          that.$message.success({
            message: "保存成功",
            duration: 1000,
            onClose: function() {
              that.$router.push({
                name: "expose_subject"
              });
            }
          });
        } else if (res.status == -1) {
          that.$message.error("参数错误");
          that.errResult = res.result;
        } else {
          that.$message.error(res.msg);
        }
        that.isLoading = false;
      });
    }
  }
};
</script>

<style scoped>
</style>
